package cn.itcast.tools.java加密;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;


public class md5 {
    public static void main() {
        String plainText = "overview_metrics:haven_server_handle_duration:histogram_quantilecluster#$#s3|group#$#haven|method#$#add_group_member|node#$#192.168.84.4-haven0001|quantile#$#0.99";
        byte[] secretBytes = null;
        try {
            secretBytes = MessageDigest.getInstance("md5").digest(plainText.getBytes());
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("没有这个md5算法！");
        }
        String md5code = new BigInteger(1, secretBytes).toString(16);
        for (int i = 0; i < 32 - md5code.length(); i++) {
            md5code = "0" + md5code;
        }
        System.out.println(md5code);
    }
}